
require('../fonts/iconfont.css')
require('../less/index.less');
require("../lib/swiper/swiper.css")

document.ready(function(){
    //  获取节点
    const rank=document.querySelector("#rank");
    const insigniaNum=document.querySelector("#insigniaNum");
    const isPunch=document.querySelector("#isPunch");
    const punchIn=document.querySelector("#punchIn");
  // until.CreateFoot('home')
    const mySwiper = new Swiper ('.swiper-container', {
        loop: true, // 循环模式选项


        // 如果需要分页器
        pagination: {
          el: '.swiper-pagination',
        },
        
        // 如果需要前进后退按钮
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev',
        },
        
      });
    function getHomeData(){
      // 获取请求ID
      let datas=localStorage.getItem('userId')
      // 发送请求
      $http.get(`/headPageInfo?userId=${datas}`,function(res){
        if(res.status===0){
          rank.textContent=res.data.rank
          insigniaNum.textContent=res.data.insigniaNum
          isPunch.textContent=res.data.isPunch==="true"?'已打卡':"今日打卡"
          punchIn.textContent=res.data.punchIn
        }
      })
    }
    getHomeData()

    isPunch.addEventListener('click',function(){
      // 获取请求ID
      let datas=localStorage.getItem('userId')
      $http.get(`/clockIn?userId=${datas}`,function(res){
        if(res.status===0){
          isPunch.textContent="已打卡"
          getHomeData()
        }
      })
    })
})